TypeScript/tests/baselines/reference/lateBoundAssignmentDeclarationSupport3.symbols
Nathan Shively-Sanders c3d41bbb73
Alias for commonjs require in JS (#39770)
* First attempt at aliases for require

* test+initial support for const x=require

* 1st round of baseline improvements

* 2nd round of baseline updates

* support property access after require

* check @type tag on require

* forbid expando missing namespaces on aliases

taken from #39558 as soon as it was created

* accept error baselines that are good, actually

* Scribbling on d.ts emit code

* use getSpecifierForModuleSymbol

* hideous hack for module.exports of aliases

* Fix module.exports.x --> export list emit

* fix isLocalImport predicate

* require only creates aliases in JS

* re-handle json imports

* update fourslash baseline

* Cleanup in the checker

1. Simplify alias resolution.
2. Simplify variable-like checking.
3. Make binding skip require calls with type tags -- they fall back to
the old require-call code and then check from there.

I haven't started on the declaration emit code since I don't know what
is going on there nearly as well.

* Function for getting module name from require call

* First round of cleanup plus a new test

Found one missing feature, not sure it's worth adding.

* more small cleanup

* more cleanup, including lint

* use trackSymbol, not serializeTypeForDeclaration

* Code review comments, plus remove unneeded code

Ad-hoc type reference resolution for `require` isn't needed anymore.

* find all refs works

* remove old ad-hoc code

* make it clear that old behaviour is not that correct

* update api baselines

* remove outdated comment

* PR feedback

1. Fix indentation
2. Add comment for exported JSON emit
3. Add test case for nested-namespace exports.

* add a fail-case test (which passes!)
2020-08-17 14:00:37 -07:00

55 lines
3.4 KiB
Plaintext

=== tests/cases/conformance/salsa/usage.js ===
const x = require("./lateBoundAssignmentDeclarationSupport3.js");
>x : Symbol(x, Decl(usage.js, 0, 5))
>require : Symbol(require)
>"./lateBoundAssignmentDeclarationSupport3.js" : Symbol(x, Decl(lateBoundAssignmentDeclarationSupport3.js, 0, 0))
const y = x["my-fake-sym"];
>y : Symbol(y, Decl(usage.js, 1, 5))
>x : Symbol(x, Decl(usage.js, 0, 5))
const z = x[x.S];
>z : Symbol(z, Decl(usage.js, 2, 5))
>x : Symbol(x, Decl(usage.js, 0, 5))
>x.S : Symbol(x.S, Decl(lateBoundAssignmentDeclarationSupport3.js, 5, 61))
>x : Symbol(x, Decl(usage.js, 0, 5))
>S : Symbol(x.S, Decl(lateBoundAssignmentDeclarationSupport3.js, 5, 61))
=== tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport3.js ===
// currently unsupported
const _sym = Symbol();
>_sym : Symbol(_sym, Decl(lateBoundAssignmentDeclarationSupport3.js, 1, 5))
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
const _str = "my-fake-sym";
>_str : Symbol(_str, Decl(lateBoundAssignmentDeclarationSupport3.js, 2, 5))
Object.defineProperty(module.exports, _sym, { value: "ok" });
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>module.exports : Symbol("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport3", Decl(lateBoundAssignmentDeclarationSupport3.js, 0, 0))
>module : Symbol(module, Decl(lateBoundAssignmentDeclarationSupport3.js, 5, 61))
>exports : Symbol("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport3", Decl(lateBoundAssignmentDeclarationSupport3.js, 0, 0))
>_sym : Symbol(_sym, Decl(lateBoundAssignmentDeclarationSupport3.js, 1, 5))
>value : Symbol(value, Decl(lateBoundAssignmentDeclarationSupport3.js, 4, 45))
Object.defineProperty(module.exports, _str, { value: "ok" });
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>module.exports : Symbol("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport3", Decl(lateBoundAssignmentDeclarationSupport3.js, 0, 0))
>module : Symbol(module, Decl(lateBoundAssignmentDeclarationSupport3.js, 5, 61))
>exports : Symbol("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport3", Decl(lateBoundAssignmentDeclarationSupport3.js, 0, 0))
>_str : Symbol(_str, Decl(lateBoundAssignmentDeclarationSupport3.js, 2, 5))
>value : Symbol(value, Decl(lateBoundAssignmentDeclarationSupport3.js, 5, 45))
module.exports.S = _sym;
>module.exports.S : Symbol(S, Decl(lateBoundAssignmentDeclarationSupport3.js, 5, 61))
>module.exports : Symbol(S, Decl(lateBoundAssignmentDeclarationSupport3.js, 5, 61))
>module : Symbol(module, Decl(lateBoundAssignmentDeclarationSupport3.js, 5, 61))
>exports : Symbol("tests/cases/conformance/salsa/lateBoundAssignmentDeclarationSupport3", Decl(lateBoundAssignmentDeclarationSupport3.js, 0, 0))
>S : Symbol(S, Decl(lateBoundAssignmentDeclarationSupport3.js, 5, 61))
>_sym : Symbol(_sym, Decl(lateBoundAssignmentDeclarationSupport3.js, 1, 5))