42 Commits
Author SHA1 Message Date
Andrey Sitnik 85bf516d71 Move to oxfmt 2026-04-07 16:07:54 +00:00
Andrey Sitnik f45d36cfdb Update dependencies 2025-10-18 14:12:14 +00:00
Andrey Sitnik d3d4d735df Update ESLint config 2025-02-19 13:43:47 +00:00
Natalie Weizenbaum 37d58e4e3d Merge remote-tracking branch 'origin/main' into rule-props 2024-08-01 17:14:41 -07:00
Andrey Sitnik 2478e19913 Declaration#variable do not have setter 2024-07-29 10:30:08 +00:00
Andrey Sitnik d5c313f25a Fix type 2024-07-29 10:29:24 +00:00
Andrey Sitnik d101a9999f Sort keys 2024-07-29 10:29:05 +00:00
beepsandGitHub aa7bd71bae Fix setter name typo in declaration.d.ts 2024-07-29 11:19:49 +01:00
Natalie Weizenbaum 14536bf865 Use explicit this return types for clone methods 2024-07-26 17:17:17 -07:00
Natalie Weizenbaum 4400498b1f Declare Node subclass attributes as getters
This makes it easier to extend these classes and override these fields
with information that's derived from other, internal fields.

This helps enable https://github.com/sass/dart-sass/issues/88
2024-07-23 18:33:56 -07:00
Andrey Sitnik 23d6dbce16 Fix node.parent.nodes type 2024-02-06 22:20:04 +01:00
Andrey Sitnik 45a1a9e8d4 Better clone types 2023-07-13 21:20:43 +02:00
Andrey Sitnik 0e3c3eb115 Simplify docs 2023-07-13 20:06:40 +02:00
Andrey Sitnik 89b7f7ac78 Update dependencies and code style 2023-07-06 13:38:48 +02:00
Andrey Sitnik 19a7e2d886 Clean up docs 2023-07-06 13:32:50 +02:00
vikaskaliramna07 e3bcdafca4 lib/declaration.d.ts: updated documentation for important 2023-07-02 11:36:25 +05:30
vikaskaliramna07 2fc3fe64d7 updated external link documentation 2023-07-02 09:51:43 +05:30
vikaskaliramna07 d087c0a758 improved paragraph for external links 2023-07-02 09:25:07 +05:30
vikaskaliramna07 3d9d33d469 fixed conflicts with API docs 2023-07-02 09:09:58 +05:30
vikaskaliramna07 0a0f0fbf05 lib/comment.d.ts: fixed conflict with API docs. 2023-07-02 09:07:14 +05:30
vikaskaliramna07 0304f50197 Update declaration.d.ts 2023-07-02 08:33:15 +05:30
Remco Haszing 902d5c277d Revert unwanted changes 2023-04-15 13:34:47 +02:00
Remco Haszing 113970af29 Remove intermediate classes for default exports 2023-04-15 13:00:25 +02:00
Remco Haszing 6849201298 Export private types
Closes #1830
2023-04-14 20:32:46 +02:00
Remco Haszing f739b0bde1 Use ESM imports in type definitions 2023-03-27 18:45:38 +02:00
Remco Haszing 676fb8a0ae Fix default exports with inheritance 2023-03-27 18:08:45 +02:00
Remco Haszing c5275ddc7b Add back support for default in type definitions 2023-03-02 12:35:05 +01:00
Remco Haszing cae533107d Fix type definitions
Many files from postcss are exported. Each of this file is written using
the syntax:

```js
module.exports = Thing
```

This should be typed as:

```ts
export = Thing
```

If such a file needs to export additional types, a namespace should be
used.

However, it was typed as:

```ts
export default thing
```

This was solved at the time in #1459 (by me) by adding the following
code to each module:

```js
Thing.default = Thing
```

Whilst affective at the time, this was not the correct solution. The
introduction of the `"module": "node16"` option in TypeScript made this
issue more apparent. I recommend to remove this in a next semver major
release.

Usage has changed as follows:

**cts**

```jsonc
// tsconfig.json
{
  "compilerOptions": {
    "module": "commonjs",
    "moduleResolution": "node16"
  }
}
```

```ts
// Old
import postcss = require('postcss')

postcss.default(/* … */)
```

```ts
// New
import postcss = require('postcss')

postcss(/* … */)
```

**cjs**

```jsonc
// tsconfig.json
{
  "compilerOptions": {
    "checkJs": true,
    "module": "commonjs",
    "moduleResolution": "node16"
  }
}
```

```ts
// Old
const postcss = require('postcss')

postcss.default(/* … */)
```

```ts
// New
const postcss = require('postcss')

postcss(/* … */)
```

**mts** / **mjs**

```jsonc
// tsconfig.json
{
  "compilerOptions": {
    "module": "node16"
  }
}
```

```ts
// Old
import postcss from 'postcss'

postcss.default(/* … */)
```

```ts
// New
import postcss from 'postcss'

postcss(/* … */)
```

**bundler**

```jsonc
// tsconfig.json
{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "module": "esnext",
    "moduleResolution": "node16"
  }
}
```

```ts
// Unchanged
import postcss from 'postcss'

postcss(/* … */)
```

**ES module interop** (Not recommended for library code!)

```jsonc
// tsconfig.json
{
  "compilerOptions": {
    "esModuleInterop": true,
    "module": "commonjs",
    "moduleResolution": "node16"
  }
}
```

```ts
// Unchanged
import postcss from 'postcss'

postcss(/* … */)
```

When compiling to CJS, it is still possible to write ESM-like syntax,
for example:

```jsonc
// Same as import postcss = require('postcss')
import * as postcss from 'postcss'
// Named imports from namespaces are allowed
import { root, Root } from 'postcss'
```

The following changes were made to `tsconfig.json`:

- `lib` was specified explicitly. By default, TypeScript includes the
  `dom` types. This is not desirable, it even causes some conflicts with
  types used by Postcss.
- `allowJs` was removed. When this is enabled, TypeScript treats `.d.ts`
  files matching `.js` files as output. This caused some unexpected
  issues where TypeScript simply ignored type errors.
- `skipLibCheck` was removed. Ideally all types just work together. This
  can be added again later if necessary.
- `esModuleInterop` was removed. Enabling this option causes TypeScript
  to allow code that is otherwise invalid. This may be useful for CLIs
  or website, but is dangerous to use for libraries.

Correcting these options also highlighted some issues in the tests.
These have been resolved. `nanodelay@1` has incorrect type definitions,
so it has been marked using `@ts-expect-error` comments.

In `test/errors.ts` were some type errors. These were marked as
`THROWS`, which signals `check-dts` a type error is expected.
This was changed to `@ts-expect-error`, which works too, but it also
works with other TypeScript tooling.

The `Postcss` type was missing some properties. As a side effect of the
corrected types, these are now available. This also affects the `Helper`
type.

Last, but not least, type definitions have been added for `postcss.mjs`.

Closes #1814
2023-02-16 16:17:58 +01:00
Andrey Sitnik 01dc9c7560 Fix Declaration.raws.value type 2022-03-15 19:24:48 +01:00
43081j 112ecaa0b2 fix: allow all raws to be extended 2021-12-12 22:24:00 +00:00
Andrey SitnikandGitHub 2c6777648a Merge pull request #1582 from hudochenkov/add-document-node-1498
Add Document node and related API (#1498)
2021-05-18 20:46:25 -04:00
Jonathan NealandAndrey Sitnik 6ac398f726 fix: tests
- Fixes the `important` prop of DeclarationProps, which should be optional.
- Adds a test for the `assign` method.
2021-05-17 08:50:29 -04:00
Jonathan NealandAndrey Sitnik f070b51ff1 feat: Node#assign
The `assign` function lets authors assign multiple properties to a node from a single object.

This can improve code clarity when updating multiple properties while offering a helpful typing experience.
2021-05-17 08:50:29 -04:00
Aleks Hudochenkov b27fcdd3a8 Specify parent type on a Root node 2021-05-17 02:38:22 +02:00
Andrey Sitnik 843ab11b6e Add Prettier 2021-03-11 19:11:37 -05:00
Andrey Sitnik 0d49399d5d Add Once and OnceExit events 2020-09-25 15:56:19 -04:00
Andrey Sitnik 6a0b8cd0cb Update plugin API in TypeDoc 2020-08-22 00:09:47 -05:00
Andrey Sitnik 2ca52f0ece Add Declaration#variable 2020-07-29 17:38:34 -07:00
Andrey Sitnik f038ae97b1 Show example with named import 2020-07-13 20:11:42 -07:00
Andrey Sitnik 7dc34d61a8 Move Node test to TS 2020-07-10 20:21:53 -07:00
Andrey Sitnik 981b016135 Update imports 2020-07-09 21:11:51 -07:00
Andrey Sitnik 8aae507a45 Clean up types and replace JSDoc to TypeDoc 2020-07-08 17:55:13 -07:00