Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions internal/ast/parseoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ func isFileProbablyExternalModule(sourceFile *SourceFile) *Node {
}

func isAnExternalModuleIndicatorNode(node *Node) bool {
if node.Flags&NodeFlagsReparsed != 0 {
return false
}
return HasSyntacticModifier(node, ModifierFlagsExport) ||
IsImportEqualsDeclaration(node) && IsExternalModuleReference(node.AsImportEqualsDeclaration().ModuleReference) ||
IsImportDeclaration(node) || IsExportAssignment(node) || IsExportDeclaration(node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ exports.default = () => {


//// [index.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export var default = () => {
return 1234;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,9 @@ const example3 = {


//// [jsFileAlternativeUseOfOverloadTag.js]
"use strict";
// These are a few examples of existing alternative uses of @overload tag.
// They will not work as expected with our implementation, but we are
// trying to make sure that our changes do not result in any crashes here.
Object.defineProperty(exports, "__esModule", { value: true });
const example1 = {
/**
* @overload Example1(value)
Expand Down Expand Up @@ -108,17 +106,115 @@ const example3 = {


//// [jsFileAlternativeUseOfOverloadTag.d.ts]
declare function Example1(value: any): any;
declare const example1: {
/**
* @overload Example1(value)
* Creates Example1
* @param value [String]
*/
constructor: (value: any, options: any) => void;
};
declare function Example2(value: any, secretAccessKey: any, sessionToken: any): any;
declare function Example2(): any;
declare const example2: {
/**
* Example 2
*
* @overload Example2(value)
* Creates Example2
* @param value [String]
* @param secretAccessKey [String]
* @param sessionToken [String]
* @example Creates with string value
* const example = new Example('');
* @overload Example2(options)
* Creates Example2
* @option options value [String]
* @example Creates with options object
* const example = new Example2({
* value: '',
* });
*/
constructor: () => void;
};
declare function evaluate(): any;
export type callback = (error: any, result: any) ;
declare const example3: {
/**
* @overload evaluate(options = {}, [callback])
* Evaluate something
* @note Something interesting
* @param options [map]
* @return [string] returns evaluation result
* @return [null] returns nothing if callback provided
* @callback callback function (error, result)
* If callback is provided it will be called with evaluation result
* @param error [Error]
* @param result [String]
* @see callback
*/
evaluate: (options: any, callback: any) => void;
};


//// [DtsFileErrors]


dist/jsFileAlternativeUseOfOverloadTag.d.ts(1,50): error TS1005: '=>' expected.
dist/jsFileAlternativeUseOfOverloadTag.d.ts(34,50): error TS1005: '=>' expected.


==== dist/jsFileAlternativeUseOfOverloadTag.d.ts (1 errors) ====
declare function Example1(value: any): any;
declare const example1: {
/**
* @overload Example1(value)
* Creates Example1
* @param value [String]
*/
constructor: (value: any, options: any) => void;
};
declare function Example2(value: any, secretAccessKey: any, sessionToken: any): any;
declare function Example2(): any;
declare const example2: {
/**
* Example 2
*
* @overload Example2(value)
* Creates Example2
* @param value [String]
* @param secretAccessKey [String]
* @param sessionToken [String]
* @example Creates with string value
* const example = new Example('');
* @overload Example2(options)
* Creates Example2
* @option options value [String]
* @example Creates with options object
* const example = new Example2({
* value: '',
* });
*/
constructor: () => void;
};
declare function evaluate(): any;
export type callback = (error: any, result: any) ;
~
!!! error TS1005: '=>' expected.
declare const example3: {
/**
* @overload evaluate(options = {}, [callback])
* Evaluate something
* @note Something interesting
* @param options [map]
* @return [string] returns evaluation result
* @return [null] returns nothing if callback provided
* @callback callback function (error, result)
* If callback is provided it will be called with evaluation result
* @param error [Error]
* @param result [String]
* @see callback
*/
evaluate: (options: any, callback: any) => void;
};

Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
--- old.jsFileAlternativeUseOfOverloadTag.js
+++ new.jsFileAlternativeUseOfOverloadTag.js
@@= skipped -54, +54 lines =@@


//// [jsFileAlternativeUseOfOverloadTag.js]
+"use strict";
// These are a few examples of existing alternative uses of @overload tag.
// They will not work as expected with our implementation, but we are
// trying to make sure that our changes do not result in any crashes here.
+Object.defineProperty(exports, "__esModule", { value: true });
const example1 = {
/**
* @overload Example1(value)
@@= skipped -51, +53 lines =@@
@@= skipped -105, +105 lines =@@


//// [jsFileAlternativeUseOfOverloadTag.d.ts]
-declare namespace example1 {
- /**
- * @overload Example1(value)
- * Creates Example1
- * @param value [String]
- */
+declare function Example1(value: any): any;
+declare const example1: {
/**
* @overload Example1(value)
* Creates Example1
* @param value [String]
*/
- function constructor(value: any): any;
-}
-declare namespace example2 {
Expand Down Expand Up @@ -66,37 +56,109 @@
- export { constructor_1 as constructor };
-}
-declare namespace example3 {
- /**
- * @overload evaluate(options = {}, [callback])
- * Evaluate something
- * @note Something interesting
- * @param options [map]
- * @return [string] returns evaluation result
- * @return [null] returns nothing if callback provided
- * @callback callback function (error, result)
- * If callback is provided it will be called with evaluation result
- * @param error [Error]
- * @param result [String]
- * @see callback
- */
+ constructor: (value: any, options: any) => void;
+};
+declare function Example2(value: any, secretAccessKey: any, sessionToken: any): any;
+declare function Example2(): any;
+declare const example2: {
+ /**
+ * Example 2
+ *
+ * @overload Example2(value)
+ * Creates Example2
+ * @param value [String]
+ * @param secretAccessKey [String]
+ * @param sessionToken [String]
+ * @example Creates with string value
+ * const example = new Example('');
+ * @overload Example2(options)
+ * Creates Example2
+ * @option options value [String]
+ * @example Creates with options object
+ * const example = new Example2({
+ * value: '',
+ * });
+ */
+ constructor: () => void;
+};
+declare function evaluate(): any;
+export type callback = (error: any, result: any) ;
+declare const example3: {
/**
* @overload evaluate(options = {}, [callback])
* Evaluate something
@@= skipped -63, +48 lines =@@
* @param result [String]
* @see callback
*/
- function evaluate(): any;
-}
-/**
- * function (error, result)
- * If callback is provided it will be called with evaluation result
- */
-type callback = (error: any, result: any) => any;
+export type callback = (error: any, result: any) ;
+ evaluate: (options: any, callback: any) => void;
+};
+
+
+//// [DtsFileErrors]
+
+
+dist/jsFileAlternativeUseOfOverloadTag.d.ts(1,50): error TS1005: '=>' expected.
+dist/jsFileAlternativeUseOfOverloadTag.d.ts(34,50): error TS1005: '=>' expected.
+
+
+==== dist/jsFileAlternativeUseOfOverloadTag.d.ts (1 errors) ====
+ declare function Example1(value: any): any;
+ declare const example1: {
+ /**
+ * @overload Example1(value)
+ * Creates Example1
+ * @param value [String]
+ */
+ constructor: (value: any, options: any) => void;
+ };
+ declare function Example2(value: any, secretAccessKey: any, sessionToken: any): any;
+ declare function Example2(): any;
+ declare const example2: {
+ /**
+ * Example 2
+ *
+ * @overload Example2(value)
+ * Creates Example2
+ * @param value [String]
+ * @param secretAccessKey [String]
+ * @param sessionToken [String]
+ * @example Creates with string value
+ * const example = new Example('');
+ * @overload Example2(options)
+ * Creates Example2
+ * @option options value [String]
+ * @example Creates with options object
+ * const example = new Example2({
+ * value: '',
+ * });
+ */
+ constructor: () => void;
+ };
+ declare function evaluate(): any;
+ export type callback = (error: any, result: any) ;
+ ~
+!!! error TS1005: '=>' expected.
+ declare const example3: {
+ /**
+ * @overload evaluate(options = {}, [callback])
+ * Evaluate something
+ * @note Something interesting
+ * @param options [map]
+ * @return [string] returns evaluation result
+ * @return [null] returns nothing if callback provided
+ * @callback callback function (error, result)
+ * If callback is provided it will be called with evaluation result
+ * @param error [Error]
+ * @param result [String]
+ * @see callback
+ */
+ evaluate: (options: any, callback: any) => void;
+ };
+
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/main1.ts(3,12): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
/main1.ts(19,4): error TS2339: Property 'default' does not exist on type '() => void'.
/main1.ts(23,8): error TS1192: Module '"/e"' has no default export.
/main1.ts(30,4): error TS2339: Property 'default' does not exist on type '0'.
/main2.mts(4,4): error TS2339: Property 'default' does not exist on type 'typeof import("/a")'.
/main2.mts(5,12): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
/main2.mts(14,8): error TS1192: Module '"/e"' has no default export.
Expand Down Expand Up @@ -43,7 +42,7 @@
==== /g.js (0 errors) ====
exports.default = 0;

==== /main1.ts (4 errors) ====
==== /main1.ts (3 errors) ====
import { x, y } from "./a"; // No y
import a1 = require("./a"); // { x: 0 }
const a2 = require("./a"); // Error in TS
Expand Down Expand Up @@ -80,8 +79,6 @@

import g1 from "./g"; // { default: 0 }
g1.default;
~~~~~~~
!!! error TS2339: Property 'default' does not exist on type '0'.
import g2 = require("./g"); // { default: 0 }
g2.default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
/main1.ts(19,4): error TS2339: Property 'default' does not exist on type '() => void'.
/main1.ts(23,8): error TS1192: Module '"/e"' has no default export.
-/main2.mts(1,13): error TS2305: Module '"./a"' has no exported member 'y'.
+/main1.ts(30,4): error TS2339: Property 'default' does not exist on type '0'.
/main2.mts(4,4): error TS2339: Property 'default' does not exist on type 'typeof import("/a")'.
/main2.mts(5,12): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
/main2.mts(14,8): error TS1192: Module '"/e"' has no default export.
Expand All @@ -18,7 +17,7 @@
/main3.cjs(2,1): error TS8002: 'import ... =' can only be used in TypeScript files.
/main3.cjs(5,8): error TS1293: ECMAScript module syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'.
/main3.cjs(8,8): error TS1293: ECMAScript module syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'.
@@= skipped -18, +16 lines =@@
@@= skipped -18, +15 lines =@@
/main3.cjs(17,8): error TS1293: ECMAScript module syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'.


Expand All @@ -31,21 +30,19 @@

==== /b.ts (0 errors) ====
export default 0;
@@= skipped -30, +28 lines =@@
@@= skipped -28, +26 lines =@@
==== /g.js (0 errors) ====
exports.default = 0;

==== /main1.ts (4 errors) ====
-==== /main1.ts (4 errors) ====
+==== /main1.ts (3 errors) ====
import { x, y } from "./a"; // No y
- ~
-!!! error TS2305: Module '"./a"' has no exported member 'y'.
import a1 = require("./a"); // { x: 0 }
const a2 = require("./a"); // Error in TS
~~~~~~~
@@= skipped -37, +35 lines =@@

import g1 from "./g"; // { default: 0 }
g1.default;
+ ~~~~~~~
+!!! error TS2339: Property 'default' does not exist on type '0'.
@@= skipped -42, +40 lines =@@
import g2 = require("./g"); // { default: 0 }
g2.default;

Expand All @@ -57,7 +54,7 @@
import a1 = require("./a"); // { x: 0 }
a1.x;
a1.default.x; // Arguably should exist but doesn't
@@= skipped -38, +38 lines =@@
@@= skipped -35, +33 lines =@@
~
!!! error TS1293: ECMAScript module syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'.
~
Expand Down
Loading
Loading