Skip to content

Commit

Permalink
Prefix builtins with globalThis.
Browse files Browse the repository at this point in the history
  • Loading branch information
daogrady committed Jan 8, 2025
1 parent 00c2bf6 commit c88d8b6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.

### Added
### Changed
- prefixed builtin types like `Promise` and `Record` with `globalType.`, to allow using names of builtin types for entities without collisions
### Deprecated
### Removed
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion lib/components/typescript.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
empty: 'Record<never, never>'
empty: 'globalThis.Record<never, never>'
}
2 changes: 1 addition & 1 deletion lib/printers/wrappers.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const createIntersectionOf = (...types) => types.join(' & ')
* createPromiseOf('string') // -> 'Promise<string>'
* ```
*/
const createPromiseOf = t => `Promise<${t}>`
const createPromiseOf = t => `globalThis.Promise<${t}>`

/**
* Wraps type into a deep require (removes all posibilities of undefined recursively).
Expand Down
6 changes: 3 additions & 3 deletions test/unit/actions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ describe('Actions', () => {
checkFunction(actions.type.members.find(fn => fn.name === 's1'), {
callCheck: signature => check.isAny(signature),
returnTypeCheck: returns => check.isAny(returns),
parameterCheck: ({full, args}) => full === 'Record'
parameterCheck: ({full, args}) => full === 'globalThis.Record'
&& checkKeyword(args[0], 'never')
&& checkKeyword(args[1], 'never')
})
checkFunction(actions.type.members.find(fn => fn.name === 'sn'), {
callCheck: signature => check.isAny(signature),
returnTypeCheck: returns => check.isAny(returns),
parameterCheck: ({full, args}) => full === 'Record'
parameterCheck: ({full, args}) => full === 'globalThis.Record'
&& checkKeyword(args[0], 'never')
&& checkKeyword(args[1], 'never')
})
Expand Down Expand Up @@ -190,7 +190,7 @@ describe('Actions', () => {

test ('Empty .actions typed as empty Record', async () => {
const { type } = astwUnbound.getAspectProperty('_NoActionAspect', 'actions')
expect(type.full === 'Record'
expect(type.full === 'globalThis.Record'
&& checkKeyword(type.args[0], 'never')
&& checkKeyword(type.args[1], 'never')
).toBe(true)
Expand Down

0 comments on commit c88d8b6

Please sign in to comment.