Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

static type checking ES module exports #46019

Closed
5 tasks
acfasj opened this issue Sep 23, 2021 · 2 comments
Closed
5 tasks

static type checking ES module exports #46019

acfasj opened this issue Sep 23, 2021 · 2 comments

Comments

@acfasj
Copy link

acfasj commented Sep 23, 2021

Suggestion

πŸ” Search Terms

List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback.

βœ… Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

Add a feature that can static type checking ES module exports

πŸ“ƒ Motivating Example

it may looks like

// file.ts
export const x = 4
export const y = 'whatever'
export const foo = () => 2

// the interface describes the what file.ts  exports
export interface module {
    x: 4
    y: string
    foo: () => number
}

πŸ’» Use Cases

Actually I asked a question on stackoverflow, and not really konw what the sugar syntax looks like if the the feature could be implemented.

// file.ts
export const x = 4
export const y = 'whatever'
export const foo = () => 2

// the interface describes the what the module exports
interface Module {
    x: 4
    y: string
    foo: () => number
}

I want the exports in file.ts satisfy the interface Module, and typescript can tell me that I export right or not

@acfasj acfasj changed the title static type checking es module exports static type checking ES module exports Sep 23, 2021
@MartinJohns
Copy link
Contributor

Duplicate of #38511.

@acfasj
Copy link
Author

acfasj commented Sep 23, 2021

closed since duplicated

@acfasj acfasj closed this as completed Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants