Skip to content

Ambient types not working for json import assertions with moduleResolution: Node16/NodeNextΒ #51691

Closed
@dnalborczyk

Description

@dnalborczyk

Bug Report

πŸ”Ž Search Terms

json import assertions ambient types

⏯ Playground Link

n/a

πŸ’» Code

locationData.json.d.ts

export interface Location {
  id: string
}

declare const locations: Location[]

export default locations

locationData.json

[
  {
    "id": "loc-1"
  }
]

index.ts

import locations from './locationsData.json' assert { type: 'json' }
import type { Location } from './locationsData.json'

tsconfig.json

{
  "compilerOptions": {
    "esModuleInterop": true,
    "module": "ESNext",
    "moduleResolution": "NodeNext",
    "outDir": "dist",
    "strict": true,
    "target": "ESNext",
  },
}

πŸ™ Actual behavior

locations is untyped (any)

πŸ™‚ Expected behavior

locations should be typed

it works as expected with "moduleResolution": "Node"

Metadata

Metadata

Assignees

Labels

Needs InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions