-
Notifications
You must be signed in to change notification settings - Fork 730
Only export @typedef type aliases in modules
#1999
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
Changes from all commits
4370aad
b71c5d1
0c55658
13d81bd
2651c3a
f1a0802
eaa057b
22c99dc
155aad8
b6b6ed8
f1c5856
16a26c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,17 +70,11 @@ func (p *Parser) reparseTags(parent *ast.Node, jsDoc []*ast.Node) { | |
| func (p *Parser) reparseUnhosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) { | ||
| switch tag.Kind { | ||
| case ast.KindJSDocTypedefTag: | ||
| // !!! Don't mark typedefs as exported if they are not in a module | ||
| typeExpression := tag.AsJSDocTypedefTag().TypeExpression | ||
| if typeExpression == nil { | ||
| break | ||
| } | ||
| export := p.factory.NewModifier(ast.KindExportKeyword) | ||
| export.Loc = tag.Loc | ||
| export.Flags = p.contextFlags | ast.NodeFlagsReparsed | ||
| modifiers := p.newModifierList(export.Loc, p.nodeSlicePool.NewSlice1(export)) | ||
|
|
||
| typeAlias := p.factory.NewJSTypeAliasDeclaration(modifiers, p.factory.DeepCloneReparse(tag.AsJSDocTypedefTag().Name()), nil, nil) | ||
| typeAlias := p.factory.NewJSTypeAliasDeclaration(nil, p.factory.DeepCloneReparse(tag.AsJSDocTypedefTag().Name()), nil, nil) | ||
|
||
| typeAlias.AsTypeAliasDeclaration().TypeParameters = p.gatherTypeParameters(jsDoc, tag) | ||
| var t *ast.Node | ||
| switch typeExpression.Kind { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| b.js(3,24): error TS2306: File 'a.js' is not a module. | ||
|
|
||
|
|
||
| ==== a.js (0 errors) ==== | ||
| /** @typedef {string} A */ | ||
|
|
||
| ==== b.js (1 errors) ==== | ||
| module.exports = { | ||
| create() { | ||
| /** @param {import("./a").A} x */ | ||
| ~~~~~ | ||
| !!! error TS2306: File 'a.js' is not a module. | ||
| function f(x) {} | ||
| return f("hi"); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,9 +19,6 @@ export type test = test; | |
|
|
||
|
|
||
| //// [test.js] | ||
| export = { | ||
| message: "" | ||
| }; | ||
| module.exports = { | ||
| message: "" | ||
| }; | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,5 @@ var x = 1 | |
|
|
||
|
|
||
| //// [index.js] | ||
| export = {}; | ||
| module.exports = {}; | ||
| var x = 1; | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,5 +49,4 @@ class Foo { | |
| } | ||
| class Bar extends Foo { | ||
| } | ||
| export = Bar; | ||
| module.exports = Bar; | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,5 +49,4 @@ class Foo { | |
| } | ||
| class Bar extends Foo { | ||
| } | ||
| export = Bar; | ||
| module.exports = Bar; | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,5 +13,4 @@ class Foo { | |
| } | ||
| class Bar extends Foo { | ||
| } | ||
| export = Bar; | ||
| module.exports = Bar; | ||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.