[X] I have checked the latest version if the bug exist there. See all available packages at npmJS.com
[X] I have followed the installation guide.
Package versions
@scania/tegel-react: >=1.9.0
Browser
Chrome
Framework
React
Version
React 18
Reproduction steps
Type definitions are missing in version 1.9.0 and above when using modern TypeScript moduleResolution options. Types for Tegels custom events are also no longer exported by @scania/tegel when using @scania/tegel-react.
Create a new React project npm create vite@latest tegel-missing-types -- --template react-ts
Install Tegel v1.8.1 npm i @scania/tegel-react@1.8.1
Import any Tegel component in any React component, ex. TdsTextField(or use my code example)
Try to autocomplete a TdsTextField property or hover over an existing property to see its type in your code editor
Import a Tds...CustomEvent type from @scania/tegel ex. import { type TdsTextFieldCustomEvent } from '@scania/tegel';
Verify that it works as it should. Yay!
Install Tegel v1.10.0 npm i @scania/tegel-react@1.10.0
Repeat steps 4 and 5
Verify that type definitions are broken
Verify that custom event types are no longer exported by @scania/tegel and are only available in @scania/tegel/loader
Could not find a declaration file for module '@scania/tegel'. '/node_modules/.pnpm/@scania+tegel@1.10.0/node_modules/@scania/tegel/dist/index.js' implicitly has an 'any' type.
There are types at '/node_modules/@scania/tegel/dist/types/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@scania/tegel' library may need to update its package.json or typings.ts(7016)
Oh no!
Code example
import { ReactNode } from 'react';
import { TdsDropdown } from '@scania/tegel-react';
const Example = (): ReactNode => {
return (
<div>
<TdsDropdown
onTdsChange={(event) => {
console.log(event);
}}
/>
This is an amazing example! Wow!
</div>
);
};
export default Example;
Screenshots
v1.8.1
v1.10.0
Expected behaviour
Tegels type definitions should be available for the consuming application.
Solution
Update package.json in the @scania/tegel package and export all type definitions:
Requirements before reporting
Package versions
@scania/tegel-react: >=1.9.0
Browser
Chrome
Framework
React
Version
React 18
Reproduction steps
Type definitions are missing in version 1.9.0 and above when using modern TypeScript
moduleResolution
options. Types for Tegels custom events are also no longer exported by@scania/tegel
when using@scania/tegel-react
.npm create vite@latest tegel-missing-types -- --template react-ts
npm i @scania/tegel-react@1.8.1
TdsTextField
(or use my code example)TdsTextField
property or hover over an existing property to see its type in your code editorTds...CustomEvent
type from@scania/tegel
ex.import { type TdsTextFieldCustomEvent } from '@scania/tegel';
npm i @scania/tegel-react@1.10.0
@scania/tegel
and are only available in@scania/tegel/loader
Code example
Screenshots
v1.8.1
v1.10.0
Expected behaviour
Tegels type definitions should be available for the consuming application.
Solution
Update
package.json
in the@scania/tegel
package and export all type definitions:Console errors
No response
Contact information
No response